{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "704d617a",
   "metadata": {},
   "source": [
    "## PyEcharts配置项"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aca8ded8",
   "metadata": {},
   "source": [
    "### 在Pyecharts中： 一切皆配置"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87eab785",
   "metadata": {},
   "source": [
    "#### 全局配置项\n",
    "- 全局配置项可通过 set_global_opts 方法设置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b9a5cfae",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts.charts import Bar, Line\n",
    "from pyecharts import options as opts\n",
    "\n",
    "from pyecharts.faker import Faker\n",
    "from pyecharts.globals import ThemeType, RenderType"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f0503119",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['草莓', '芒果', '葡萄', '雪梨', '西瓜', '柠檬', '车厘子']"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Faker.choose()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "4f652a5a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[126, 129, 137, 83, 130, 57, 72]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Faker.values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1292ab26",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/v5/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"8462e4aaba70456fbaba8752ff7b391b\" style=\"width:700px; height:400px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_8462e4aaba70456fbaba8752ff7b391b = echarts.init(\n",
       "                    document.getElementById('8462e4aaba70456fbaba8752ff7b391b'), 'white', {renderer: 'canvas'});\n",
       "                var option_8462e4aaba70456fbaba8752ff7b391b = {\n",
       "    \"backgroundColor\": \"white\",\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5546\\u5bb6A\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                124,\n",
       "                58,\n",
       "                59,\n",
       "                61,\n",
       "                123,\n",
       "                23,\n",
       "                34\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5546\\u5bb6B\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                35,\n",
       "                43,\n",
       "                55,\n",
       "                85,\n",
       "                106,\n",
       "                148,\n",
       "                147\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb6A\",\n",
       "                \"\\u5546\\u5bb6B\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"type\": \"plain\",\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"20%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"align\": \"left\",\n",
       "            \"padding\": 10,\n",
       "            \"itemGap\": 5,\n",
       "            \"itemWidth\": 30,\n",
       "            \"itemHeight\": 15,\n",
       "            \"inactiveColor\": \"#ccc\",\n",
       "            \"icon\": \"roundRect\",\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"formatter\": \"{a}: {b}-{c}\",\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"black\",\n",
       "        \"borderColor\": \"white\",\n",
       "        \"borderWidth\": 1,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"type\": \"category\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u8349\\u8393\",\n",
       "                \"\\u8292\\u679c\",\n",
       "                \"\\u8461\\u8404\",\n",
       "                \"\\u96ea\\u68a8\",\n",
       "                \"\\u897f\\u74dc\",\n",
       "                \"\\u67e0\\u6aac\",\n",
       "                \"\\u8f66\\u5398\\u5b50\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisLine\": {\n",
       "                \"show\": false,\n",
       "                \"onZero\": true,\n",
       "                \"onZeroAxisIndex\": 0\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"show\": false,\n",
       "                \"alignWithLabel\": false,\n",
       "                \"inside\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"\\u67f1\\u5f62\\u56fe\",\n",
       "            \"link\": \"https://www.baidu.com\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtext\": \"\\u526f\\u6807\\u9898\",\n",
       "            \"sublink\": \"https://www.baidu.com\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"left\": \"20px\",\n",
       "            \"top\": \"0px\",\n",
       "            \"padding\": 10,\n",
       "            \"itemGap\": 5,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"piecewise\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 150,\n",
       "        \"text\": [\n",
       "            \"max\",\n",
       "            \"min\"\n",
       "        ],\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"blue\",\n",
       "                \"green\",\n",
       "                \"red\"\n",
       "            ],\n",
       "            \"opacity\": 0.7\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": true,\n",
       "        \"splitNumber\": 5,\n",
       "        \"hoverLink\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"top\": \"0%\",\n",
       "        \"right\": \"5%\",\n",
       "        \"padding\": 5,\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 14,\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"showDetail\": true,\n",
       "        \"showDataShadow\": true,\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_8462e4aaba70456fbaba8752ff7b391b.setOption(option_8462e4aaba70456fbaba8752ff7b391b);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x2484abceb30>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = (\n",
    "    Bar(\n",
    "        # InitOpts: 初始化配置项\n",
    "        init_opts=opts.InitOpts(\n",
    "            width='700px',\n",
    "            height='400px',   # 图表画布大小，css长度单位\n",
    "            renderer=RenderType.CANVAS,  # 渲染风格,可选：canvas,svg\n",
    "            page_title='网页标题',\n",
    "            theme=ThemeType.WHITE,  # 主题\n",
    "            bg_color='white'  # 背景颜色\n",
    "        )\n",
    "    )\n",
    "    .add_xaxis(Faker.choose())\n",
    "\n",
    "    .add_yaxis('商家A', Faker.values())\n",
    "    .add_yaxis('商家B', Faker.values())\n",
    "\n",
    "    # 全局配置项\n",
    "    .set_global_opts(\n",
    "\n",
    "        # TitleOpts: 标题配置项\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title='柱形图',  # 主标题\n",
    "            title_link='https://www.baidu.com',  # 主标题点击跳转链接\n",
    "            title_target='blank',  # blank新窗口打开，self 当前窗口打开\n",
    "\n",
    "            subtitle='副标题',  # 副标题\n",
    "            subtitle_link='https://www.baidu.com',\n",
    "            subtitle_target='blank',\n",
    "\n",
    "            # 位置\n",
    "            pos_left='20px',\n",
    "            pos_top='0px',\n",
    "            # pos_right\n",
    "            # pos_bottom\n",
    "            padding=10,  # 内边距\n",
    "            item_gap=5,  # 主标题和副标题之间的间隙\n",
    "        ),\n",
    "\n",
    "        # DataZoomOpts：区域缩放配置项\n",
    "        datazoom_opts=opts.DataZoomOpts(\n",
    "            is_show=True,  # 是否显示组件\n",
    "            type_='slider',  # 组件的类型：slider, inside\n",
    "            is_realtime=True,  # 拖动时是否实时更新图表\n",
    "            range_start=20,  # 数据窗口的起始百分比\n",
    "            range_end=80,  # 数据窗口的结束百分比\n",
    "            orient='horizontal',  # horizontal 或 vertical\n",
    "            is_zoom_lock=False,  # 是否锁定选择区域\n",
    "        ),\n",
    "\n",
    "        # LegendOpts: 图例配置项\n",
    "        legend_opts=opts.LegendOpts(\n",
    "            # 图例类型： plain普通图例，scroll:可以滚动翻页的图例,用于图例较多的情况\n",
    "            type_='plain',\n",
    "            is_show=True,  # 是否显示图例\n",
    "            pos_left='20%',  # 图例位置:pos_left,pos_right,pos_top,pos_bottom\n",
    "            orient='vertical', # horizontal 或 vertical\n",
    "\n",
    "            # 选择模式\n",
    "            #  True: 开启图例点击\n",
    "            #  False: 关闭图例点击\n",
    "            #  single: 单选\n",
    "            #  multiple: 多选\n",
    "            selected_mode=\"multiple\",\n",
    "\n",
    "            # 图标和文字的位置\n",
    "            align='left',\n",
    "            padding=10,  # 内边距\n",
    "            item_gap=5,  # 图例中每项之间的间距\n",
    "            item_width=30,  # 项的宽度\n",
    "            item_height=15,  # 项的高度\n",
    "            inactive_color='#ccc',  # 图例关闭时的颜色,\n",
    "\n",
    "            # PyEcharts常见的图标： circle,rect,roundRect,triangle, diamond,arrow\n",
    "            legend_icon='roundRect'\n",
    "        ),\n",
    "\n",
    "        # VisualMapOpts：视觉映射配置项\n",
    "        visualmap_opts=opts.VisualMapOpts(\n",
    "            is_show=True,\n",
    "            type_='color',  # color 或 size\n",
    "            min_=0,  # 最小值\n",
    "            max_=150,  # 最大值\n",
    "            range_opacity=0.7,  # 图元和文字透明度\n",
    "            range_text=['max', 'min'],  # 两端的文本\n",
    "            range_color=['blue', 'green', 'red'],  # 过渡颜色\n",
    "\n",
    "            orient='vertical', # horizontal 或 vertical\n",
    "            pos_right='5%',\n",
    "            pos_top='0%',\n",
    "            is_piecewise=True,  # 是否为分段型\n",
    "            is_inverse=True  # 是否反转\n",
    "        ),\n",
    "\n",
    "        # TooltipOpts: 提示框配置项\n",
    "        tooltip_opts=opts.TooltipOpts(\n",
    "            is_show=True,\n",
    "\n",
    "            # 触发类型\n",
    "            #  item: 数据项，一般用于:散点图，柱形图，饼图\n",
    "            #  axis: 坐标轴，提示线，主要用于条形图，折线图等\n",
    "            trigger='item',\n",
    "            # 触发条件：\n",
    "            #  mousemove, click, mousemove|click\n",
    "            trigger_on='click',\n",
    "\n",
    "            is_show_content=True,  # 是否显示提示框浮层\n",
    "\n",
    "            # 标签内容的格式\n",
    "            #  字符串中的模板变量：\n",
    "            #  {a}: 系列名series_name\n",
    "            #  {b}: 数据名\n",
    "            #  {c}：值\n",
    "            formatter='{a}: {b}-{c}',\n",
    "\n",
    "            background_color='black',  # 背景颜色\n",
    "            border_color='white',  # 边框颜色\n",
    "            border_width=1,  # 边框宽度\n",
    "        ),\n",
    "\n",
    "        # AxisOpts: 坐标轴配置项\n",
    "        xaxis_opts=opts.AxisOpts(\n",
    "            is_show=True,  # 是否显示X轴\n",
    "\n",
    "            # 坐标轴类型:\n",
    "            #   value: 数值轴，用于连续数据\n",
    "            #   category: 类目轴，适用于离散数据，比如：星期一，星期二等\n",
    "            #   time: 时间轴，适用于连续的时序数据\n",
    "            type_='category'\n",
    "        ),\n",
    "\n",
    "        yaxis_opts=opts.AxisOpts(\n",
    "            # is_show=False,\n",
    "            # 不显示y轴的线\n",
    "            axisline_opts=opts.AxisLineOpts(is_show=False),\n",
    "            # 不显示y轴的刻度\n",
    "            axistick_opts=opts.AxisTickOpts(is_show=False)\n",
    "\n",
    "        )\n",
    "    )\n",
    "\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "74f9f833",
   "metadata": {},
   "source": [
    "#### 系列配置项\n",
    "- 系列配置项可通过 set_series_opts 方法设置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "4601b3bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts.charts import Line"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "007f00a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/v5/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"9b8d8a3e6d274d6988d44690f0e4ba3d\" style=\"width:700px; height:400px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_9b8d8a3e6d274d6988d44690f0e4ba3d = echarts.init(\n",
       "                    document.getElementById('9b8d8a3e6d274d6988d44690f0e4ba3d'), 'white', {renderer: 'canvas'});\n",
       "                var option_9b8d8a3e6d274d6988d44690f0e4ba3d = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u5546\\u5bb6A\",\n",
       "            \"connectNulls\": false,\n",
       "            \"xAxisIndex\": 0,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"\\u5c0f\\u7c73\",\n",
       "                    127\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u4e09\\u661f\",\n",
       "                    141\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u534e\\u4e3a\",\n",
       "                    91\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u82f9\\u679c\",\n",
       "                    26\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9b45\\u65cf\",\n",
       "                    69\n",
       "                ],\n",
       "                [\n",
       "                    \"VIVO\",\n",
       "                    92\n",
       "                ],\n",
       "                [\n",
       "                    \"OPPO\",\n",
       "                    93\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"color\": \"red\",\n",
       "                \"rotate\": -40,\n",
       "                \"margin\": 8,\n",
       "                \"fontSize\": 14,\n",
       "                \"fontStyle\": \"italic\",\n",
       "                \"fontWeight\": \"bold\",\n",
       "                \"fontFamily\": \"Arial\"\n",
       "            },\n",
       "            \"logBase\": 10,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 2,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"dashed\",\n",
       "                \"color\": \"green\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"max\",\n",
       "                        \"symbol\": \"pin\",\n",
       "                        \"symbolSize\": 50\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"color\": \"red\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"color\": \"blue\",\n",
       "                \"borderColor\": \"green\",\n",
       "                \"borderWidth\": 2,\n",
       "                \"opacity\": 0.6\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u5546\\u5bb6B\",\n",
       "            \"connectNulls\": false,\n",
       "            \"xAxisIndex\": 0,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"\\u5c0f\\u7c73\",\n",
       "                    137\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u4e09\\u661f\",\n",
       "                    48\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u534e\\u4e3a\",\n",
       "                    57\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u82f9\\u679c\",\n",
       "                    138\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9b45\\u65cf\",\n",
       "                    148\n",
       "                ],\n",
       "                [\n",
       "                    \"VIVO\",\n",
       "                    60\n",
       "                ],\n",
       "                [\n",
       "                    \"OPPO\",\n",
       "                    117\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"color\": \"red\",\n",
       "                \"rotate\": -40,\n",
       "                \"margin\": 8,\n",
       "                \"fontSize\": 14,\n",
       "                \"fontStyle\": \"italic\",\n",
       "                \"fontWeight\": \"bold\",\n",
       "                \"fontFamily\": \"Arial\"\n",
       "            },\n",
       "            \"logBase\": 10,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 2,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"dashed\",\n",
       "                \"color\": \"green\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"max\",\n",
       "                        \"symbol\": \"pin\",\n",
       "                        \"symbolSize\": 50\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"color\": \"red\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"color\": \"blue\",\n",
       "                \"borderColor\": \"green\",\n",
       "                \"borderWidth\": 2,\n",
       "                \"opacity\": 0.6\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb6A\",\n",
       "                \"\\u5546\\u5bb6B\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"axis\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c73\",\n",
       "                \"\\u4e09\\u661f\",\n",
       "                \"\\u534e\\u4e3a\",\n",
       "                \"\\u82f9\\u679c\",\n",
       "                \"\\u9b45\\u65cf\",\n",
       "                \"VIVO\",\n",
       "                \"OPPO\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"\\u6298\\u7ebf\\u56fe\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_9b8d8a3e6d274d6988d44690f0e4ba3d.setOption(option_9b8d8a3e6d274d6988d44690f0e4ba3d);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x2484abcfac0>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = (\n",
    "    Line(\n",
    "        # InitOpts: 初始化配置项\n",
    "        init_opts=opts.InitOpts(\n",
    "            width='700px',\n",
    "            height='400px'\n",
    "        )\n",
    "    )\n",
    "    .add_xaxis(Faker.choose())\n",
    "\n",
    "    .add_yaxis('商家A', Faker.values())\n",
    "    .add_yaxis('商家B', Faker.values())\n",
    "\n",
    "    # 全局配置项\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title='折线图'),\n",
    "        # 提示线\n",
    "        tooltip_opts=opts.TooltipOpts(trigger='axis')\n",
    "    )\n",
    "\n",
    "    # 系列配置项\n",
    "    .set_series_opts(\n",
    "\n",
    "        # ItemStyleOpts: 图元样式配置项\n",
    "        itemstyle_opts=opts.ItemStyleOpts(\n",
    "            # 图的颜色\n",
    "            #  使用纯色\n",
    "            #  RGB, rgb(120, 120, 120)\n",
    "            #  RGBA, rgba(120, 120, 120, 0.5)\n",
    "            #  十六进制: #ccc\n",
    "            color='blue',\n",
    "            opacity=0.6,\n",
    "            border_color='green',\n",
    "            border_width=2\n",
    "        ),\n",
    "\n",
    "        # LineStyleOpts: 线样式配置项\n",
    "        linestyle_opts=opts.LineStyleOpts(\n",
    "            is_show=True,\n",
    "            width=2,  # 线宽\n",
    "            color='green', # 线颜色\n",
    "            type_='dashed'  # solid，dashed,dotted\n",
    "        ),\n",
    "\n",
    "        # LabelOpts：标签配置项\n",
    "        label_opts=opts.LabelOpts(\n",
    "            is_show=True,\n",
    "            # 位置：top, left, right, bottom\n",
    "            #       inside, insideLeft,insideRight, insideTop,insideBottom\n",
    "            #     等\n",
    "            position='top',  # 位置\n",
    "            color='red',  # 颜色\n",
    "            font_size=14,  # 大小\n",
    "            font_family='Arial',  # 字体\n",
    "            font_style='italic',  # 是否斜体,italic\n",
    "            font_weight='bold',  # 是否加粗 bold\n",
    "\n",
    "            # 标签旋转，-90到90\n",
    "            rotate=-40\n",
    "        ),\n",
    "\n",
    "        # MarkPointOpts:标记点配置项\n",
    "        markpoint_opts=opts.MarkPointOpts(\n",
    "            data=[\n",
    "                # type_: 特殊标记类型，min, max, average\n",
    "                # symbol: 标记点的图形\n",
    "                # symbol_size：标记点的大小\n",
    "                opts.MarkPointItem(type_='max', symbol='pin',symbol_size=50),\n",
    "                opts.MarkPointItem(type_='min'),\n",
    "            ]\n",
    "        ),\n",
    "\n",
    "        # 标记线\n",
    "        markline_opts=opts.MarkLineOpts(\n",
    "            data=[\n",
    "                opts.MarkLineItem(type_='average')\n",
    "            ],\n",
    "            label_opts=opts.LabelOpts(\n",
    "                color='red'\n",
    "            )\n",
    "        )\n",
    "\n",
    "    )\n",
    "\n",
    ")\n",
    "c.render_notebook()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
